home *** CD-ROM | disk | FTP | other *** search
/ PC Action 1997 January / PCA0197.ISO / demos / ambe / roxy / roxy.dxr / 00008_generic key-mouse handlers.ls < prev    next >
Encoding:
Text File  |  1996-10-28  |  14.1 KB  |  408 lines

  1. on mouseDown
  2.   if objectp(oPuppeteer) then
  3.     DoHotspots(oPuppeteer)
  4.   end if
  5. end
  6.  
  7. on keyDown
  8.   global oStoryteller, oPuppeteer, oUtility, gPsionSpins, gPsionFrames, gVoid, gDeferredTransit
  9.   if the keyDownScript <> EMPTY then
  10.     exit
  11.   end if
  12.   set passwordState to getState(oStoryteller, #PlayerIsUsingLaptop)
  13.   set frameStack to getProp(the lsMultiframes of oPuppeteer, #passwordEntry)
  14.   if oUtility(mIsAlphaNum, the key) then
  15.     set alphaNum to 1
  16.   end if
  17.   if passwordState = #prompting then
  18.     killVideo()
  19.     if alphaNum = 1 then
  20.       setState(oStoryteller, #PlayerIsUsingLaptop, #password)
  21.       set passwordState to #password
  22.     else
  23.       setState(oStoryteller, #PlayerIsUsingLaptop, 0)
  24.       set passwordState to 0
  25.       updateDisplay(oPuppeteer)
  26.     end if
  27.   end if
  28.   if passwordState = #password then
  29.     set lsAttempt to getProp(the lsStateData of oStoryteller, #passwordAttempt)
  30.     set multiSprite to #None
  31.     repeat with i = 10 to 48
  32.       if getPos(frameStack, the castNum of sprite i) then
  33.         set multiSprite to i
  34.         exit repeat
  35.       end if
  36.     end repeat
  37.     if multiSprite = #None then
  38.       alert("keyDown: Whoa, something's really wrong here")
  39.       exit
  40.     end if
  41.     if (the key = ENTER) or (the key = RETURN) or (count(lsAttempt) > 5) then
  42.       cursorOff()
  43.       set rightAnswer to 0
  44.       if count(lsAttempt) = count(["W", "I", "S", "D", "O", "M"]) then
  45.         repeat with i = 1 to count(lsAttempt)
  46.           set testChar to getAt(lsAttempt, i)
  47.           if (getAt(["W", "I", "S", "D", "O", "M"], i) = testChar) or (getAt(["w", "i", "s", "d", "o", "m"], i) = testChar) then
  48.             set rightAnswer to 1
  49.             next repeat
  50.           end if
  51.           set rightAnswer to 0
  52.           exit repeat
  53.         end repeat
  54.       end if
  55.       if rightAnswer then
  56.         cursorOff()
  57.         setState(oStoryteller, #PlayerIsUsingLaptop, #startup)
  58.         updateDisplay(oPuppeteer)
  59.         pushVideo()
  60.         wait(#videoStop)
  61.         killVideo()
  62.         if getProp(the lsStateData of oStoryteller, #ghostsRemaining) = [] then
  63.           setState(oStoryteller, #PlayerIsUsingLaptop, 0)
  64.           setState(oStoryteller, #showMontage, 0)
  65.           goTo(#OfficeMonitor_PTsuite)
  66.           wait(90)
  67.           pushVideo()
  68.           wait(#videoStop)
  69.           killVideo()
  70.           loadMultiframes(#BT_checkBox)
  71.           loadMultiframes(#BT_align_left)
  72.           loadMultiframes(#BT_align_right)
  73.           loadMultiframes(#BT_bias1)
  74.           loadMultiframes(#BT_bias2)
  75.           loadMultiframes(#BT_bias3)
  76.           loadMultiframes(#BT_psionFrames)
  77.           setState(oStoryteller, #BT_fragStatus, #spinningNow)
  78.           if gPsionSpins = [0, 0, 0] then
  79.             set gPsionFrames to gVoid
  80.           end if
  81.           goTo(#OfficeMonitor_alignment)
  82.         else
  83.           setState(oStoryteller, #PlayerIsUsingLaptop, #crashing)
  84.           updateDisplay(oPuppeteer, #fastVideo)
  85.           wait(#videoStop)
  86.           setState(oStoryteller, #PlayerIsUsingLaptop, #crashed)
  87.           updateDisplay(oPuppeteer)
  88.         end if
  89.       else
  90.         set the castNum of sprite multiSprite to getAt(frameStack, count(frameStack))
  91.         updateStage()
  92.         wait(60)
  93.         setState(oStoryteller, #PlayerIsUsingLaptop, 0)
  94.         updateDisplay(oPuppeteer)
  95.         wait(15)
  96.         setState(oStoryteller, #PlayerIsUsingLaptop, #prompting)
  97.         updateDisplay(oPuppeteer)
  98.         set frustration to getState(oStoryteller, #passwordFrustration)
  99.         if integerp(frustration) then
  100.           set frustration to frustration + 1
  101.           setProp(the lsStateData of oStoryteller, #passwordFrustration, [frustration])
  102.           if (frustration mod 5) = 0 then
  103.             soundEffect(#bigHint)
  104.           end if
  105.         end if
  106.       end if
  107.       exit
  108.     end if
  109.     if the key = BACKSPACE then
  110.       if count(lsAttempt) then
  111.         deleteAt(lsAttempt, count(lsAttempt))
  112.       end if
  113.     end if
  114.     if alphaNum then
  115.       append(lsAttempt, the key)
  116.     else
  117.       nothing()
  118.     end if
  119.     set the castNum of sprite multiSprite to getAt(frameStack, count(lsAttempt) + 1)
  120.     updateStage()
  121.   end if
  122.   if the number of menus > 0 then
  123.     pass()
  124.     exit
  125.   end if
  126.   if the commandDown then
  127.     set foo to the key
  128.     if "01234567" contains foo then
  129.       do("set the soundLevel to " & foo)
  130.     end if
  131.     if "XxQq" contains the key then
  132.       set gDeferredTransit to "quitGame( oStoryteller )"
  133.     end if
  134.   end if
  135.   dontPassEvent()
  136. end
  137.  
  138. on setPlayerIsUsingLaptop suggestion
  139.   global oStoryteller, oPuppeteer
  140.   set newValue to #None
  141.   if suggestion = 0 then
  142.     purgeMultiframes(#passwordEntry)
  143.     unFreezeInventory()
  144.     killVideo()
  145.     set newValue to 0
  146.     setProp(the lsStateData of oStoryteller, #passwordAttempt, [])
  147.   end if
  148.   if suggestion = #prompting then
  149.     loadMultiframes(#passwordEntry)
  150.     set newValue to #prompting
  151.   end if
  152.   if suggestion = #crashing then
  153.     set newValue to #crashing
  154.   end if
  155.   if suggestion = #crashed then
  156.     set newValue to #crashed
  157.   end if
  158.   if suggestion = #restart then
  159.     set newValue to #restart
  160.   end if
  161.   if suggestion = #off then
  162.     set newValue to #off
  163.     setProp(the lsStateData of oStoryteller, #passwordAttempt, [])
  164.     set the queuedSound of oPuppeteer to #computerOff
  165.   end if
  166.   if suggestion = #warmingUp then
  167.     set newValue to #warmingUp
  168.     soundEffect(#computerStart)
  169.   end if
  170.   if suggestion = #password then
  171.     freezeInventory()
  172.     set newValue to #password
  173.   end if
  174.   if suggestion = #startup then
  175.     purgeMultiframes(#passwordEntry)
  176.     unFreezeInventory()
  177.     set newValue to #startup
  178.   end if
  179.   if newValue <> #None then
  180.     setProp(the lsStateData of oStoryteller, #PlayerIsUsingLaptop, [newValue])
  181.   end if
  182. end
  183.  
  184. on setPlayerIsExaminingPhone suggestion
  185.   global oStoryteller
  186.   if suggestion = 0 then
  187.     endLoop(#phoneRoxy)
  188.     endLoop(#phoneDead)
  189.   else
  190.     endLoop(#phoneRinging)
  191.     setProp(the lsStateData of oStoryteller, #ghostlyPhoneCall, [#dontRingPlease])
  192.   end if
  193.   setProp(the lsStateData of oStoryteller, #playerIsExaminingPhone, [suggestion])
  194. end
  195.  
  196. on spawnGhostlyEvent
  197.   global oStoryteller, oPuppeteer
  198.   if getState(oStoryteller, #BarOnline) = 0 then
  199.     exit
  200.   end if
  201.   set currentLoc to getState(oStoryteller, #currentLocation)
  202.   set hauntList to getProp(the lsStateData of oStoryteller, #cameraFeedbackRemaining)
  203.   repeat with i in hauntList
  204.     if (i = #peekFakeout) or (i = #rightBehindYou) then
  205.     end if
  206.     if i = #ghostKnife then
  207.       set forbiddenLocations to [#DiningRmKitchenEntry2, #HallKitchenEntryOpen, #Ghse_D_S, #Ghse_D_W, #Ghse_E_W, #Ghse_P_KitchenDoorCU, #Ghse_P_KitchenEntry]
  208.       if (the gHotSublist of oPuppeteer <> #kitchen) and (getPos(forbiddenLocations, currentLoc) = 0) then
  209.         setState(oStoryteller, #PeekDisplay, #ghostKnife)
  210.         exit repeat
  211.       end if
  212.     end if
  213.     if i = #crazyLR then
  214.       set forbiddenLocations to [#HallLivingRmEntry, #HallNwall, #HallExit, #PorchDoorCU]
  215.       if (the gHotSublist of oPuppeteer <> #livingRm) and (the gHotSublist of oPuppeteer <> #Study) and (getPos(forbiddenLocations, currentLoc) = 0) then
  216.         setState(oStoryteller, #PeekDisplay, #crazyLR)
  217.         exit repeat
  218.       end if
  219.     end if
  220.     if i = #crazyDR then
  221.       if (the gHotSublist of oPuppeteer <> #diningRm) and (currentLoc <> #KitchenDiningRmEntry) and (the gHotSublist of oPuppeteer <> #Study) then
  222.         setState(oStoryteller, #PeekDisplay, #crazyDR)
  223.         exit repeat
  224.       end if
  225.     end if
  226.     if i = #KdKnob then
  227.       set forbiddenLocations to [#DiningRmKitchenEntry2, #HallKitchenEntryOpen, #Ghse_D_S, #Ghse_D_W, #Ghse_E_W, #Ghse_P_KitchenDoorCU, #Ghse_P_KitchenEntry]
  228.       if (the gHotSublist of oPuppeteer <> #kitchen) and (getPos(forbiddenLocations, currentLoc) = 0) then
  229.         setState(oStoryteller, #PeekDisplay, #KdKnob)
  230.         exit repeat
  231.       end if
  232.     end if
  233.     if i = #ghostlyKey then
  234.       if (the gHotSublist of oPuppeteer <> #MBR) and (currentLoc <> #UHallMasterBedrmEntry) then
  235.         setState(oStoryteller, #PeekDisplay, #ghostlyKey)
  236.         exit repeat
  237.       end if
  238.     end if
  239.     if i = #bloodBath then
  240.       if (the gHotSublist of oPuppeteer <> #Marg) and (currentLoc <> #UHallMargRoomEntry) then
  241.         setState(oStoryteller, #PeekDisplay, #bloodBath)
  242.         exit repeat
  243.       end if
  244.     end if
  245.   end repeat
  246. end
  247.  
  248. on assertEdwinGhost
  249.   global gCPU
  250.   if inState(#hauntsRemaining, #lakeGhost2) then
  251.     if (getState(oStoryteller, #playerHasCrowbar) = 0) or (inState(#hauntsRemaining, #lakeGhost) = 0) then
  252.       if gCPU = #PC then
  253.         suspendSounds(#fadeOut)
  254.       end if
  255.       pushVideo()
  256.       wait(#videoStop)
  257.       if gCPU = #PC then
  258.         restoreSounds(#fadeIn)
  259.       end if
  260.       trimState(#hauntsRemaining, #lakeGhost2)
  261.     end if
  262.   end if
  263. end
  264.  
  265. on setcurrentPageInBarManual suggestion
  266.   global oStoryteller, oPuppeteer, gOriginPoint
  267.   cursorOff()
  268.   set frameStack to getProp(the lsMultiframes of oPuppeteer, #BarManual)
  269.   set pageList to [0, 1, 2, 3, 4, 5]
  270.   set currentPage to getState(oStoryteller, #currentPageInBarManual)
  271.   set bookMark to getPos(pageList, currentPage)
  272.   if suggestion = #next then
  273.     if bookMark = count(pageList) then
  274.       setState(oStoryteller, #playerIsReadingBarManual, 0)
  275.       updateDisplay(oPuppeteer)
  276.     else
  277.       set pageSprite to 0
  278.       set shadowSprite to 0
  279.       repeat with guess = 10 to 48
  280.         if getPos(frameStack, the castNum of sprite guess) then
  281.           set shadowSprite to guess
  282.           set pageSprite to guess + 1
  283.           exit repeat
  284.         end if
  285.       end repeat
  286.       set myLocation to the loc of sprite pageSprite
  287.       set the castNum of sprite shadowSprite to the castNum of sprite pageSprite
  288.       set the loc of sprite pageSprite to point(300, -300) + gOriginPoint
  289.       updateStage()
  290.       do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #nextPage))
  291.       setProp(the lsStateData of oStoryteller, #currentPageInBarManual, list(getAt(pageList, bookMark + 1)))
  292.       set the castNum of sprite pageSprite to getAt(frameStack, bookMark + 3)
  293.       set the loc of sprite pageSprite to myLocation
  294.       soundEffect(#pageTurn)
  295.       updateStage()
  296.     end if
  297.   end if
  298.   if suggestion = #previous then
  299.     if bookMark = 1 then
  300.       setState(oStoryteller, #playerIsReadingBarManual, 0)
  301.       updateDisplay(oPuppeteer)
  302.     else
  303.       set pageSprite to 0
  304.       set shadowSprite to 0
  305.       repeat with guess = 10 to 48
  306.         if getPos(frameStack, the castNum of sprite guess) then
  307.           set shadowSprite to guess
  308.           set pageSprite to guess + 1
  309.           exit repeat
  310.         end if
  311.       end repeat
  312.       set myLocation to the loc of sprite pageSprite
  313.       set the castNum of sprite shadowSprite to the castNum of sprite pageSprite
  314.       set the loc of sprite pageSprite to point(300, -300) + gOriginPoint
  315.       updateStage()
  316.       do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #prevPage))
  317.       setProp(the lsStateData of oStoryteller, #currentPageInBarManual, list(getAt(pageList, bookMark - 1)))
  318.       set the castNum of sprite pageSprite to getAt(frameStack, bookMark + 1)
  319.       set the loc of sprite pageSprite to myLocation
  320.       soundEffect(#pageTurn)
  321.       updateStage()
  322.     end if
  323.   end if
  324. end
  325.  
  326. on setplayerIsReadingBarManual suggestion
  327.   global oStoryteller, oPuppeteer
  328.   setProp(the lsStateData of oStoryteller, #currentPageInBarManual, [0])
  329.   setProp(the lsStateData of oStoryteller, #playerIsReadingBarManual, list(suggestion))
  330.   if suggestion = 1 then
  331.     setTransition(oPuppeteer, #fadeIn)
  332.   else
  333.     setTransition(oPuppeteer, #fadeIn)
  334.   end if
  335. end
  336.  
  337. on setcurrentPageInDiary suggestion
  338.   global oStoryteller, oPuppeteer, gOriginPoint
  339.   cursorOff()
  340.   set frameStack to getProp(the lsMultiframes of oPuppeteer, #dreamDiary)
  341.   set pageList to [1, 2, 3, 5, 6]
  342.   set currentPage to getState(oStoryteller, #currentPageInDiary)
  343.   set bookMark to getPos(pageList, currentPage)
  344.   if suggestion = #next then
  345.     if bookMark = count(pageList) then
  346.       setState(oStoryteller, #playerIsReadingDreamDiary, 0)
  347.       updateDisplay(oPuppeteer)
  348.     else
  349.       set pageSprite to 0
  350.       set shadowSprite to 0
  351.       repeat with guess = 10 to 48
  352.         if getPos(frameStack, the castNum of sprite guess) then
  353.           set shadowSprite to guess
  354.           set pageSprite to guess + 1
  355.           exit repeat
  356.         end if
  357.       end repeat
  358.       set myLocation to the loc of sprite pageSprite
  359.       set the castNum of sprite shadowSprite to the castNum of sprite pageSprite
  360.       set the loc of sprite pageSprite to point(300, -300) + gOriginPoint
  361.       updateStage()
  362.       do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #nextPage))
  363.       setProp(the lsStateData of oStoryteller, #currentPageInDiary, list(getAt(pageList, bookMark + 1)))
  364.       set the castNum of sprite pageSprite to getAt(frameStack, bookMark + 3)
  365.       set the loc of sprite pageSprite to myLocation
  366.       soundEffect(#pageTurn)
  367.       updateStage()
  368.     end if
  369.   end if
  370.   if suggestion = #previous then
  371.     if bookMark = 1 then
  372.       setState(oStoryteller, #playerIsReadingDreamDiary, 0)
  373.       updateDisplay(oPuppeteer)
  374.     else
  375.       set pageSprite to 0
  376.       set shadowSprite to 0
  377.       repeat with guess = 10 to 48
  378.         if getPos(frameStack, the castNum of sprite guess) then
  379.           set shadowSprite to guess
  380.           set pageSprite to guess + 1
  381.           exit repeat
  382.         end if
  383.       end repeat
  384.       set myLocation to the loc of sprite pageSprite
  385.       set the castNum of sprite shadowSprite to the castNum of sprite pageSprite
  386.       set the loc of sprite pageSprite to point(300, -300) + gOriginPoint
  387.       updateStage()
  388.       do("puppetTransition " & getProp(getProp(the lsMachineProfile of oPuppeteer, #transitions), #prevPage))
  389.       setProp(the lsStateData of oStoryteller, #currentPageInDiary, list(getAt(pageList, bookMark - 1)))
  390.       set the castNum of sprite pageSprite to getAt(frameStack, bookMark + 1)
  391.       set the loc of sprite pageSprite to myLocation
  392.       soundEffect(#pageTurn)
  393.       updateStage()
  394.     end if
  395.   end if
  396. end
  397.  
  398. on setplayerIsReadingDreamDiary suggestion
  399.   global oStoryteller, oPuppeteer
  400.   setProp(the lsStateData of oStoryteller, #currentPageInDiary, [1])
  401.   setProp(the lsStateData of oStoryteller, #playerIsReadingDreamDiary, list(suggestion))
  402.   if suggestion = 1 then
  403.     setTransition(oPuppeteer, #fadeIn)
  404.   else
  405.     setTransition(oPuppeteer, #fadeIn)
  406.   end if
  407. end
  408.